import '@/style/global.css'
import './index.css'

// 引入公用js，测试提取公用代码
import base from '@/util/base.js'

// 引入模块js，测试代码分片/按需加载
// import { mod1, mod2 } from '@/components/index.js'


/**
 * 入口函数
 */
function main(){
  const hash = window.location.hash || '#mod1'

  // 测试：http://127.0.0.1:8080/index.html#mod1
  if (hash === '#mod1') {
    import('@/components/module1.js').then(({ default: mod1 }) => {
      addNodes(mod1.name)
    })
  }
  if (hash === '#mod2'){
    import('@/components/module2.js').then(({ default: mod2 }) => {
      addNodes(mod2.name)
    })
  }

}

function addNodes(str){
  

  let htmlStr = '';

  htmlStr += `<p class="index">欢迎来到页面：index; </p>`
  htmlStr += `<p class="index">加载的模块为：${str}</p>`
  htmlStr += `<p class="index">indexApi：${base.api.getIndexDara}</p>`
  htmlStr += `<p class="index">module1Api：${base.api.getIndexDara}</p>`

  document.querySelector('.main').innerHTML = htmlStr;
}

main()